from django.db import models


# Create your models here.
def path_and_rename(instance, filename):
    comic_name = instance.name
    print(comic_name, " ", filename)
    return "Comics/{}/{}".format(comic_name, filename)


class Comic(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=100, null=False)
    author = models.CharField(max_length=100, verbose_name="作者")
    cover = models.ImageField(upload_to=path_and_rename, null=False)
    comic_url = models.FileField(upload_to=path_and_rename, null=False)
    introduction = models.TextField()
    isShow = models.BooleanField(default=True, verbose_name="是否展示")

    def __str__(self):
        return self.name + " " + self.author

    pass
